package com.tzw.controller;

import com.tzw.pojo.BasicLeaveWord;
import com.tzw.pojo.ModuleOfProduct;
import com.tzw.service.BasicLeaveWordSerivce;
import com.tzw.service.ModuleOfProductService;
import com.tzw.untils.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 联系我们接口
 * */
@Controller
@RequestMapping("/contactUs")
public class ContactUsController {
    @Autowired
    private ModuleOfProductService moduleOfProductService;
    @Autowired
    private BasicLeaveWordSerivce basicLeaveWordSerivce;
    @GetMapping("/")
    public String aboutView(Model model){
        List<ModuleOfProduct> productList = moduleOfProductService.list();
        model.addAttribute("prdList",productList);
        return "/contact_Us";
    }
    @GetMapping("/consult")
    @ResponseBody
    public RestResponse advisory(BasicLeaveWord basicLeaveWord){
        if(basicLeaveWord == null)
            return RestResponse.failure("提交信息不能为空!!!");
        boolean save = basicLeaveWordSerivce.commitLeaveWord(basicLeaveWord);
        return save==true?RestResponse.success():RestResponse.failure("提交失败!!!");
    }
}
